/*
 * @Description:
 * @Author: zheng yiliang
 * @Date: 2021-03-13 18:13:07
 * @LastEditTime: 2021-04-08 21:18:56
 * @LastEditors: zheng yiliang
 */
import request from '@/utils/request'

// 根据角色id异步获取路由列表
export function getRoutes (roleId) {
  return request({
    url: '/routes',
    method: 'get',
    params: { roleId }
  })
}

// 根据token获取用户角色
export function getInfo () {
  return request({
    url: '/roles/userInfo',
    method: 'get'
  })
}

// 获取所有角色列表
export function getRoles (data) {
  return request({
    url: '/roles/allRoles',
    method: 'get',
    params: data
  })
}

// 新增角色
export function addRoles (data) {
  return request({
    url: '/roles/add',
    method: 'post',
    data
  })
}

// 更新角色
export function updateRoles (data) {
  return request({
    url: '/roles/update',
    method: 'put',
    data
  })
}

// 删除角色
export function delRoles (data) {
  return request({
    url: '/roles/delete',
    method: 'delete',
    data
  })
}

// 权限列表
export function getTree () {
  return request({
    url: '/roles/rightTree',
    method: 'get'
  })
}

// 设置角色权限
export function setRoleRights (data) {
  return request({
    url: '/roles/rights/set',
    method: 'put',
    data
  })
}

// 取消角色授权
export function cancelRoleRights (data) {
  return request({
    url: '/roles/rights/cancel',
    method: 'delete',
    data
  })
}

// 获取所有权限列表==一维数组
export function getAllRights () {
  return request({
    url: '/rights/list',
    method: 'get'
  })
}
